<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>原型</title>
  </head>
  <body>
    <script>
      /* function add() {
        // return {};
      }
      var t = new add();
      console.log(t); */

      /* function create() {
        if (Math.random() > 0.5) {
          return [];
        } else {
          return {};
        }
      }

      var obj = new create();
      // 如果得到obj的构造函数的名称
      console.log(obj.__proto__.constructor.name); */

      /* var a = 1;

      function m() {
        a++; // 2
      }

      function m2() {
        var a = 3;
        m();
        console.log(a); // 3
      }

      m2();
      console.log(a); // 2 */

      var abc = (function () {
        var a = 1; // 不希望污染全局
        var b = 2; // 不希望污染全局

        function c() {
          console.log(a + b);
        }

        return c;
      })();
    </script>
  </body>
</html>
